package main

import (
	"fmt"
	"log"
	"net/http"
	"time"
)

func main() {
	timeCount()
	//get 请求处理
	//doGet()
	//httpdemo()
}
func httpdemo() {
	//注册一个路由函数
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte("hello words"))
	})
	//注册一个路由函数
	http.HandleFunc("/de", func(writer http.ResponseWriter, request *http.Request) {
		fmt.Fprint(writer, "芮旭乐")
	})
	//监听4000端口 创建一个https 服务
	http.ListenAndServe(":4000", nil)
}

// get 请求方式读取数据
func doGet() {
	resp, err := http.Get("http://www.qq.com")
	if err != nil {
		log.Printf("get err= %v", err)
	}
	data := make([]byte, 1024*1024)
	n, _ := resp.Body.Read(data)
	//get 请求的返回的内容
	log.Println(string(data[:n]))

}
func timeCount() {
	//获取当前时间的对象
	now := time.Now()
	log.Printf(now.Format("2006-01-02 15:04:05"))
	//毫秒
	log.Println(now.Unix())
	//微秒
	log.Println(now.UnixNano() / 1000)
	//纳秒
	log.Println(now.UnixNano())
	//当前时间的后一天
	log.Println(now.Add(time.Duration(time.Hour * 24)).Format("2006-01-02 15:04:05"))
}
